/**
 * NewTopicAction.java 1.0 2007-5-7 下午02:28:11,创建 by yangfan
 */


package org.in4j.bbs.action.topic;

import java.sql.Timestamp;

import org.in4j.bbs.action.AbstractAction;
import org.in4j.bbs.model.Topic;
import org.in4j.bbs.service.TopicService;

/**
 *
 * @author yangfan
 * @version 1.0 2007-5-7 下午02:28:11,创建
 */
@SuppressWarnings("serial")
public class NewTopicAction extends AbstractAction
{
	private int boardId;
	private Topic topic;
	private TopicService topicService;

	@Override
	public String execute() throws Exception
	{
		if(boardId == 0) return INDEX;
		topic.setPublishTime(new Timestamp(System.currentTimeMillis()));
		topic.setAuthor(getOnlineInfo().getUser());
		topic.setStatus(Topic.STATUS_COMMON);
		topic.setReplyCount(0);
		topic.setType(Topic.TYPE_TOPIC);
		topic.setUpdateUser(topic.getAuthor().getNickname());
		topic.setUpdateTime(topic.getPublishTime());
		topicService.addNewTopic(boardId,topic);
		System.out.println("-----add a new topic");
		return SUCCESS;
	}

	public int getBoardId()
	{
		return boardId;
	}

	public void setBoardId(int boardId)
	{
		this.boardId = boardId;
	}

	public Topic getTopic()
	{
		return topic;
	}

	public void setTopic(Topic topic)
	{
		this.topic = topic;
	}

	public void setTopicService(TopicService topicService)
	{
		this.topicService = topicService;
	}
}
